//
//  JCMyPageViewController.m
//  ABookOfCartoon
//
//  Created by 美国大狗 on 15-5-13.
//  Copyright (c) 2015年 Power Of Ants. All rights reserved.
//

#import "JCMyPageViewController.h"
#import "JCDataCollectManager.h"
#import "JCDetailsViewController.h"
#import "delicateOfCartoonViewController.h"

@interface JCMyPageViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,retain)UIButton *button;
@property(nonatomic,retain)UIButton *button1;
@property(nonatomic,retain)UIButton *button2;
@property(nonatomic,retain)UIButton *button3;
@property(nonatomic,retain)UIButton *button4;
@property(nonatomic,retain)UITableView *tableView;
@property(nonatomic,retain)UIView *view1;
@property(nonatomic,retain)UIView *view2;
@property(nonatomic,retain)UIView *view3;
@property(nonatomic,retain)UIView *view4;
@property(nonatomic,retain)NSMutableArray *Arr;
@property(nonatomic,retain)UIBarButtonItem *rightButton;
@property(nonatomic,retain)JCDataCollectManager *dbmanager1;

@end

@implementation JCMyPageViewController

- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = YES;
    
    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view
    [self button];
    
    
    
    self.navigationItem.title = @"个人中心";
    
    UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"top5"]];
    image.frame = CGRectMake(0, 0, ScreenFramF, ScreenFramS);
    [self.view addSubview:image];
    
    
    //左侧侧边栏
//    self.navigationController.navigationBar.translucent = NO;
//    self.tabBarController.tabBar.translucent = NO;
//    UIImageView *naView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 64, self.view.frame.size.height - 64)];
//    naView.userInteractionEnabled = YES;
//    naView.backgroundColor = [UIColor whiteColor];
//    [self.view addSubview:naView];
//    [naView release];
//    
    
    
    //最近阅读Button
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    _button.frame = CGRectMake(0, 0, 64, 80);
    
//    _button.backgroundColor = [UIColor clearColor];
    //[_button setImage:[UIImage imageNamed:@"6"] forState:UIControlStateNormal];
    [_button setTintColor:[UIColor whiteColor]];
    [_button setTitle:@"分享" forState:UIControlStateNormal];
    _button.titleLabel.font = [UIFont systemFontOfSize:20];
    [_button addTarget:self action:@selector(personal) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_button];
    //个人中心
    self.button2 = [UIButton buttonWithType:UIButtonTypeSystem];
    _button2.frame = CGRectMake(0, 80, 64, 80);
    [_button2 setTitle:@"收藏" forState:UIControlStateNormal];
    [_button2 setTintColor:[UIColor whiteColor]];
    _button2.titleLabel.font = [UIFont systemFontOfSize:20];
    //[_button2 setImage:[UIImage imageNamed:@"1"] forState:UIControlStateNormal];
    [_button2 addTarget:self action:@selector(collect) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_button2];
    

}
- (void)haha
{

    
    self.dbmanager1 = [JCDataCollectManager shareInstance];
    [_dbmanager1 openDB];
    self.Arr = [_dbmanager1 selectInfo];
    NSLog(@"%@",_Arr);
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(64, 0, self.view.frame.size.width - 64, self.view.frame.size.height) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    [_tableView release];

}

//-(void)creatTableView1
//{
//    self.dbmanager1 = [JCDataCollectManager shareInstance];
//    self.Arr = [_dbmanager1 selectInfo];
//    NSLog(@"%@",_Arr);
//    
//    UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"top5"]];
//    image.frame = CGRectMake(0, 0, ScreenFramF, ScreenFramS);
//    [self.view addSubview:image];
//    
//    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(64, 0, self.view.frame.size.width - 64, self.view.frame.size.height) style:UITableViewStylePlain];
//    _tableView.delegate = self;
//    _tableView.dataSource = self;
//    [self.view addSubview:_tableView];
//    
//
//    [_tableView release];
//
//    
//}
//
-(void)personal
{
    self.title = @"个人中心";
    [UMSocialSnsService presentSnsIconSheetView:self appKey:@"507fcab25270157b37000010"shareText:@"你要分享的文字"shareImage:[UIImage imageNamed:@"top5"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToRenren,nil]delegate:self];
    
    [self.tableView removeFromSuperview];
    
}

-(void)collect
{
    
    JCMyPageCollectionViewController *collection = [[JCMyPageCollectionViewController alloc]init];
    [self.navigationController pushViewController:collection animated:YES];
//    self.title = @"收藏";
//    [self creatTableView1];
//    
//    self.rightButton = self.editButtonItem;
//    self.editButtonItem.title = nil;
//    _rightButton.title = @"编辑";
//    self.navigationItem.rightBarButtonItem = _rightButton;
    
}
//-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//{
//    return _Arr.count;
//}
//-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    static NSString *reuse = @"reuse";
//    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
//    if (!cell) {
//        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
//    }
//    cell.textLabel.text = [_Arr[indexPath.row] BookName];
//    return cell;
//    
//}
//-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    delicateOfCartoonViewController *de = [[delicateOfCartoonViewController alloc] init];
//    de.sb = [_Arr[indexPath.row] BookName];
//    [self.navigationController pushViewController:de animated:YES];
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
//}
//
//
//-(void)setEditing:(BOOL)editing animated:(BOOL)animated
//{
//    //调用父类的编辑方法
//    [super setEditing:editing animated:animated];
//    [_tableView setEditing:editing animated:animated];
//    if (!editing) {
//        self.navigationItem.rightBarButtonItem.title = @"编辑";
//    } else {
//        self.navigationItem.rightBarButtonItem.title = @"完成";
//    }
//}
//-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    
//    return YES;
//}
//
//
//-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return UITableViewCellEditingStyleDelete;
//}
//-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    if (editingStyle == UITableViewCellEditingStyleDelete) {
//        [_Arr removeObjectAtIndex:indexPath.row];
//        NSArray *arr = @[indexPath];
//        
//        [_tableView deleteRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationLeft];
//    }
//}
//-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    if (_dbmanager1) {
//        [_dbmanager1 deleteInfowithName:[_Arr[indexPath.row] BookName]];
//    }
//    
//    return @"删除";
//}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */
}
@end
